<%@page import="qingke.util.Const"%>
<%@page import="qingke.bean.Page"%>
<%@page import="qingke.mybatis.pojo.Store"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>店铺</title>
<link href="${pageContext.request.contextPath }/css/news.css"
	type="text/css" rel="stylesheet" />
<script src="${pageContext.request.contextPath }/js/jquery-1.8.3.min.js"></script>
<script src="${pageContext.request.contextPath }/js/menu.js"></script>
<jsp:include page="top.jsp" />
<style type="">
.page {
	text-align: center;
	margin-top: 50px;
}

.page a {
	text-decoration: none;
	border: 1px solid #f9d52b;
	padding: 5px 7px;
	color: #767675;
	cursor: pointer;
}
</style>
</head>
<%
	String select = request.getParameter("select");
	if (select != null) {
		session.setAttribute("select", select);
	} else {
		session.removeAttribute("select");
	}
%>
<%
	List<Store> stores = null;
	Object storesObject = session.getAttribute("stores");
	if (storesObject != null) {
		if (storesObject instanceof List) {
			stores = (List<Store>) storesObject;
		}
	}
%>
<%
	Page storePage = null;
	Object storePageObject = session.getAttribute("storePage");
	if (storePageObject != null) {
		if (storePageObject instanceof Page) {
			storePage = (Page) storePageObject;
		}
	}
%>
<body style="height: 80%">

	<br />
	<!--内容-->
	<div class="main">
		<div class="mainl">
			<div class="mainl-s">
				<ul>
					<li><a href="#" class="bg">店铺索引<br />
					</a></li>
				</ul>
			</div>
			<div class="mainl-c">
				<ul>
					<li><a href="#">酒水饮料<br /> <span>Drinks</span></a></li>
					<li><a href="#">蔬菜水果<br /> <span>vegetable and
								fruit</span></a></li>
					<li><a href="#">土特产<br /> <span>Native products</span></a></li>

				</ul>
			</div>

		</div>
		<div class="mainr">
			<div class="mainr-s">
				<div class="mainr-sl pr">
					<p>
						店铺中心<br /> <span>PRODUCT CENTER</span>
					</p>
				</div>
				<div class="mainr-sr">
					<a href="#">当前位置</a> ><a href="#"> 首页</a> ><a href="#"> 店铺中心</a>

				</div>

			</div>
			<div class="mainr-tu">
				<ul>
					<%
						if (stores != null) {
							for (Store store : stores) {
					%>
					<li><a href="chanp2.jsp"> <img src="images/chan02.png" /></a>
						<p>
							<a href="dianpu2.jsp"><%=store.getStoreName()%></a>
						</p></li>
					<%
						}
						}
					%>
				</ul>
			</div>
		</div>
		<div class="mainr-pg">
			<ul>
				<%
					if (storePage != null) {
						double displayPageDOUBLE = (double) storePage.getCurrentPage() / (double) Const.PAGE_STORE_NUMBER;
						int displayPage = (int) Math.ceil(displayPageDOUBLE);
						double dispalyPageAllDOUBLE = (double) storePage.getTotalPage() / (double) Const.PAGE_STORE_NUMBER;
						int displayPageAll = (int) Math.ceil(dispalyPageAllDOUBLE);
						if (storePage.getCurrentPage() != 1) {
				%>
				<li><a role="button"
					href="Store/getStoreAjax?NumberOfPage=<%=1%>">首页</a></li>
				<li><a role="button"
					href="Store/getStoreAjax?NumberOfPage=<%=storePage.getCurrentPage() - 1%>">上一页</a></li>
				<%
					}
				%>
				<%
					if (storePage.getTotalPage() >= Const.PAGE_STORE_NUMBER) {
							for (int i = (displayPage - 1) * Const.PAGE_STORE_NUMBER
									+ 1; i <= (displayPage * Const.PAGE_STORE_NUMBER < storePage.getTotalPage()
											? displayPage * Const.PAGE_STORE_NUMBER
											: storePage.getTotalPage()); i++) {
								if (i == storePage.getCurrentPage()) {
				%>
				<li><a role="button"
					href="javascript:volid(0)" href="#" disabled="disabled"
					style="color: #c0c0c0"><%=i%></a></li>
				<%
					} else {
				%>
				<li><a role="button"
					href="Store/getStoreAjax?NumberOfPage=<%=i%>"><%=i%></a></li>
				<%
					}
							}
						} else {
							for (int i = 1; i < storePage.getTotalPage() + 1; i++) {
								if (i == storePage.getCurrentPage()) {
				%>
				<li><a role="button"
					href="javascript:volid(0)" href="#" disabled="disabled"
					style="color: #c0c0c0"><%=i%></a></li>
				<%
					} else {
				%>
				<li><a role="button"
					href="Store/getStoreAjax?NumberOfPage=<%=i%>"><%=i%></a></li>
				<%
					}
							}
						}
				%>
				<%
					if (storePage.getCurrentPage() != storePage.getTotalPage()) {
				%>
				<li><a role="button"
					href="Store/getStoreAjax?NumberOfPage=<%=storePage.getCurrentPage() + 1%>">下一页</a></li>
				<li><a role="button"
					href="Store/getStoreAjax?NumberOfPage=<%=storePage.getTotalPage()%>">尾页</a></li>
				<%
					}
				%>
				<li>共<%=storePage.getTotalPage()%>页
				</li>
				<li>跳转到<input id="yeshutiaozhuan"
					style="width: 30px; margin-left: 5px; margin-right: 5px" />页
					<button role="button" onclick="ToAPage()">跳转</button></li>
				<%
					}
				%>
			</ul>
		</div>
	</div>
	<br />
	<div>
		<jsp:include page="foot.jsp" />
	</div>
	<script>
function prevent(e) {
        e.preventDefault ? e.preventDefault() : e.returnValue = false;
    }
    function digitInput(e) {
        var c = e.charCode || e.keyCode; //FF、Chrome IE下获取键盘码
        if ((c != 8 && c != 46 && // 8 - Backspace, 46 - Delete
                (c < 37 || c > 40) && // 37 (38) (39) (40) - Left (Up) (Right) (Down) Arrow
                (c < 48 || c > 57) && // 48~57 - 主键盘上的0~9
                (c < 96 || c > 105)) // 96~105 - 小键盘的0~9
                || e.shiftKey) { // Shift键，对应的code为16
            prevent(e); // 阻止事件传播到keypress
        }
    }
    $(function(){
        $("#yeshutiaozhuan").keydown(function(e) {
            digitInput(e);
        });
});
   function ToAPage(){
	   var NumberOfPage = $("#yeshutiaozhuan").val();
	   window.location.href='Store/getStoreAjax?NumberOfPage=' + NumberOfPage;
   }
   
</script>
</body>
</html>
